//
//  ZTCollectionViewCell.m
//  练习
//
//  Created by hcios on 2017/7/7.
//  Copyright © 2017年 hcios. All rights reserved.
//

#import "ZTCollectionViewCell.h"
#import "UIImageView+WebCache.h"

#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width
#define SCREEN_Height [UIScreen mainScreen].bounds.size.height
#define FONT_NAME_LTH @"FZLanTingHeiS-R-GB"

@implementation ZTCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setupSubViews];
    }
    return self;
}


-(void)setupSubViews{
    //背景
    _backImgView = [[UIImageView alloc] initWithFrame:self.bounds];
    _backImgView.layer.cornerRadius = 4;
    _backImgView.layer.masksToBounds = YES;
    [self addSubview:_backImgView];
    
    //名称
    _nameLab = [[UILabel alloc] initWithFrame:CGRectMake(15, self.frame.size.height - 30, self.frame.size.width, 20)];
    [_nameLab setTextColor:[UIColor whiteColor]];
    [_nameLab setFont:[UIFont fontWithName:FONT_NAME_LTH size:15]];
    _nameLab.textAlignment = NSTextAlignmentLeft;
    _nameLab.shadowColor = [UIColor grayColor];
    _nameLab.shadowOffset = CGSizeMake(1, 1);
    [_backImgView addSubview:_nameLab];
    
    //标题
    _titleLab = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(_nameLab.frame) - 55, self.frame.size.width, 30)];
    [_titleLab setTextColor:[UIColor whiteColor]];
    [_titleLab setFont:[UIFont fontWithName:FONT_NAME_LTH size:18]];
    _titleLab.textAlignment = NSTextAlignmentLeft;
    _titleLab.shadowColor = [UIColor grayColor];
    _titleLab.shadowOffset = CGSizeMake(1, 1);
    [_backImgView addSubview:_titleLab];
    
    
}


-(void)setCellModel:(ZTModel *)cellModel{
    _cellModel = cellModel;
    _nameLab.text = cellModel.name;
    [_backImgView sd_setImageWithURL:[NSURL URLWithString:cellModel.image_url] placeholderImage:[UIImage imageNamed:@"zhanWeiTu"]];
    _titleLab.text = cellModel.title;
}

-(void)click:(id)sender{
    if (self.delegate && [self.delegate respondsToSelector:@selector(gesAuthor:)]) {
        [self.delegate gesAuthor:sender];
    }
}

-(void)modelWithDict:(NSDictionary *)dict{
    [_backImgView sd_setImageWithURL:[NSURL URLWithString:dict[@"front_cover_photo_url"]] placeholderImage:[UIImage imageNamed:@"zhanWeiTu"]];
    _titleLab.text = dict[@"name"];
    _nameLab.text = [NSString stringWithFormat:@"%@ /%@天 /%@图",dict[@"start_day"],dict[@"day"],dict[@"photo_count"]];
}







@end
